package com.ruitu.health_1.mvp.model;

import com.ruitu.arad.base.BaseModel;
import com.ruitu.health_1.dao.bean.Collect;
import com.ruitu.router_module.bean.cart.CouponList;
import com.ruitu.health_1.dao.http.APIRetrofit;
import com.ruitu.router_module.bean.BaseResult2;
import com.ruitu.router_module.bean.PageModel2;
import com.ruitu.router_module.bean.user.Address;
import com.ruitu.router_module.bean.user.Wallet;

import java.util.List;

import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;

public class UserInfoModel {
    public static class AddressM extends BaseModel {
        public Observable<BaseResult2> addAddress(RequestBody body) {
            return APIRetrofit.getDefault().addAddress(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

        public Observable<BaseResult2> updateAddress(RequestBody body) {
            return APIRetrofit.getDefault().updateAddress(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

        public Observable<BaseResult2> deleteAddress(RequestBody body) {
            return APIRetrofit.getDefault().deleteAddress(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }

        public Observable<BaseResult2<List<Address>>> addressList(String body) {
            return APIRetrofit.getDefault().addressList(body)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }
    }

    public static class CouponListM extends BaseModel {
        public Observable<BaseResult2<PageModel2<CouponList>>> couponList(int pageNum, int pageSize, String memberId, String useStatus) {
            return APIRetrofit.getDefault().couponList(pageNum, pageSize, memberId, useStatus)
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribeOn(Schedulers.io());
        }
    }

    public static class ChangeHeadImgM extends BaseModel {
        public Observable<BaseResult2> changeHeadImg(MultipartBody body) {
            return APIRetrofit.getDefault().changeHeadImg(body)
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribeOn(Schedulers.io());
        }

        public Observable<BaseResult2> changeUserInfo(RequestBody body) {
            return APIRetrofit.getDefault().userInfoEdit(body)
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribeOn(Schedulers.io());
        }
    }


    public static class CollectListM extends BaseModel {
        public Observable<BaseResult2<PageModel2<Collect>>> collectList(int pageNum, int pageSize, String memberId){
            return APIRetrofit.getDefault().collectList(pageNum, pageSize, memberId)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }
    }

    public static class WalletM extends BaseModel {
        public Observable<BaseResult2<Wallet>> getWalletInfo(String id,String type){
            return APIRetrofit.getDefault().getWalletInfo(id, type)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread());
        }
    }

}
